/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cs575.dbentities;

import cs575.dbentities.Task;
import cs575.dbentities.User;
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author bms
 */
@Entity
@Table(name = "task_user", catalog = "tasks_management", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "TaskUser.findAll", query = "SELECT t FROM TaskUser t"),
    @NamedQuery(name = "TaskUser.findByTaskId", query = "SELECT t FROM TaskUser t WHERE t.taskUserPK.taskId = :taskId"),
    @NamedQuery(name = "TaskUser.findByUserId", query = "SELECT t FROM TaskUser t WHERE t.taskUserPK.userId = :userId"),
    @NamedQuery(name = "TaskUser.findByReadTask", query = "SELECT t FROM TaskUser t WHERE t.readTask = :readTask"),
    @NamedQuery(name = "TaskUser.findByEditTask", query = "SELECT t FROM TaskUser t WHERE t.editTask = :editTask"),
    @NamedQuery(name = "TaskUser.findByDeleteTask", query = "SELECT t FROM TaskUser t WHERE t.deleteTask = :deleteTask"),
    @NamedQuery(name = "TaskUser.findBySetTaskPermission", query = "SELECT t FROM TaskUser t WHERE t.setTaskPermission = :setTaskPermission"),
    @NamedQuery(name = "TaskUser.findByCompleteTask", query = "SELECT t FROM TaskUser t WHERE t.completeTask = :completeTask")})
public class TaskUser implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected TaskUserPK taskUserPK;
    @Basic(optional = false)
    @Column(name = "readTask", nullable = false)
    private boolean readTask;
    @Basic(optional = false)
    @Column(name = "editTask", nullable = false)
    private boolean editTask;
    @Basic(optional = false)
    @Column(name = "deleteTask", nullable = false)
    private boolean deleteTask;
    @Basic(optional = false)
    @Column(name = "setTaskPermission", nullable = false)
    private boolean setTaskPermission;
    @Basic(optional = false)
    @Column(name = "completeTask", nullable = false)
    private boolean completeTask;
    @JoinColumn(name = "user_id", referencedColumnName = "user_id", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private User user;
    @JoinColumn(name = "task_id", referencedColumnName = "task_id", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Task task;

    public TaskUser() {
    }

    public TaskUser(TaskUserPK taskUserPK) {
        this.taskUserPK = taskUserPK;
    }

    public TaskUser(TaskUserPK taskUserPK, boolean readTask, boolean editTask, boolean deleteTask, boolean setTaskPermission, boolean completeTask) {
        this.taskUserPK = taskUserPK;
        this.readTask = readTask;
        this.editTask = editTask;
        this.deleteTask = deleteTask;
        this.setTaskPermission = setTaskPermission;
        this.completeTask = completeTask;
    }

    public TaskUser(int taskId, int userId) {
        this.taskUserPK = new TaskUserPK(taskId, userId);
    }

    public TaskUserPK getTaskUserPK() {
        return taskUserPK;
    }

    public void setTaskUserPK(TaskUserPK taskUserPK) {
        this.taskUserPK = taskUserPK;
    }

    public boolean getReadTask() {
        return readTask;
    }

    public void setReadTask(boolean readTask) {
        this.readTask = readTask;
    }

    public boolean getEditTask() {
        return editTask;
    }

    public void setEditTask(boolean editTask) {
        this.editTask = editTask;
    }

    public boolean getDeleteTask() {
        return deleteTask;
    }

    public void setDeleteTask(boolean deleteTask) {
        this.deleteTask = deleteTask;
    }

    public boolean getSetTaskPermission() {
        return setTaskPermission;
    }

    public void setSetTaskPermission(boolean setTaskPermission) {
        this.setTaskPermission = setTaskPermission;
    }

    public boolean getCompleteTask() {
        return completeTask;
    }

    public void setCompleteTask(boolean completeTask) {
        this.completeTask = completeTask;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public Task getTask() {
        return task;
    }

    public void setTask(Task task) {
        this.task = task;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (taskUserPK != null ? taskUserPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TaskUser)) {
            return false;
        }
        TaskUser other = (TaskUser) object;
        if ((this.taskUserPK == null && other.taskUserPK != null) || (this.taskUserPK != null && !this.taskUserPK.equals(other.taskUserPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "cs575.coresystem.TaskUser[ taskUserPK=" + taskUserPK + " ]";
    }
    
}
